package _0325二维数组;

import java.util.Arrays;

public class Work05 {

	public static void main(String[] args) {
		/* java定义一个3*5的二维数组，用来存储某班级3位学员的5门课的成绩
		定义一个3*5的二维数组，用来存储某班级3位学员的5门课的成绩；这5门课
		 按存储顺序依次为：Java，JSP，CoreJava，MySQL和HTML5。
		*/
		int [][] scores = new int [3][5];
		int [] sums = new int [3];
		System.out.println("Java\t"+"JSP\t"+"CoreJava"+"MySQL\t"+"HTML5\t");
		for (int i = 0;i < scores.length;i++) {
			for(int j = 0;j < scores[i].length;j++) {
				scores[i][j] = (int) (Math.random() * 100);
				System.out.print(scores[i][j]+"\t");
			}System.out.print("\n");
		}
		for(int i = 0;i < scores.length;i++) {
			int sum = 0;
			for(int j = 0;j <scores[i].length;j++) {
				sum += scores[i][j];
			}
			sums[i] = sum;
		}System.out.println("三个学员五门课总分是："+Arrays.toString(sums));
		System.out.println("Java\t"+"JSP\t"+"CoreJava\t"+"MySQL\t"+"HTML5\t");
	    for(int j = 0;j<5;j++) {
			float avg = 0.0F,sum1= 0.0F;
			for(int i = 0;i<3;i++) {
				sum1 += scores[i][j];
			}
			avg =sum1/3;
			System.out.print(avg+"\t");
		}
		
	}
}
